<?php
	class Bitmap {
		var $source;
		var $result;
		var $sourceURI;
		var $width;
		var $height;
		function Bitmap($srcFile=NULL){
			if($srcFile){
				$this->load($srcFile);
			}
		}
		
		function load($src){
			$fileLoaded = false;
			if(file_exists($src)){
				$fileLoaded = true;
				$this->sourceURI = $src;
				$this->source = imagecreatefromjpeg($src);
				$size = getimagesize($src);
				$this->width = $size[0];
				$this->height = $size[1];
			}
			return $fileLoaded;
		}
		
		function resize($width,$height){
			$this->result = imagecreatetruecolor($width,$height);
			return imagecopyresampled(
						$this->result,
						$this->source,
						0,
						0,
						0,
						0,
						$width,
						$height,
						$this->width,
						$this->height);
		}
		
		function saveAs($srcDest,$quality=90){
			return imagejpeg($this->result,$srcDest,$quality);
		}
	}
?>